from flask import Flask

app = Flask(__name__)

@app.route("/")
def index():
    return """
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>Python WEB 课程留言系统</title>
  <style>
    body { font-family: Arial, sans-serif; background:#f9f9f9; margin:0; padding:0; }
    header { background:#fff; padding:20px; border-bottom:1px solid #ddd; }
    h1 { margin:0; font-size:20px; }
    main { max-width:800px; margin:20px auto; padding:0 16px; }
    form { background:#fff; padding:16px; border-radius:6px; border:1px solid #ddd; }
    label { display:block; margin-bottom:6px; font-weight:bold; }
    input[type="text"], textarea {
      width:100%; padding:8px; border:1px solid #ccc; border-radius:4px;
    }
    textarea { min-height:80px; resize:vertical; }
    button {
      margin-top:10px; background:#2563eb; color:#fff;
      padding:8px 16px; border:none; border-radius:4px; cursor:pointer;
    }
    .messages { margin-top:20px; }
    .message {
      background:#fff; padding:12px; border:1px solid #ddd; border-radius:6px;
      margin-bottom:10px;
    }
    .meta { font-size:12px; color:#666; margin-bottom:6px; }
  </style>
</head>
<body>
  <header>
    <h1>欢迎使用课程留言系统</h1>
  </header>

  <main>
    <!-- 添加留言表单 -->
    <form method="post" action="">
      <label for="author">昵称</label>
      <input type="text" id="author" name="author" placeholder="请输入昵称" />

      <label for="content" style="margin-top:10px;">留言内容</label>
      <textarea id="content" name="content" placeholder="说点什么…" required></textarea>

      <button type="submit">发布留言</button>
    </form>

    <!-- 留言列表 -->
    <div class="messages">
      <div class="message">
        <div class="meta">小明 · 2025-08-15 10:23</div>
        <div class="text">这是一个示例留言，Python 后端会替换这里。</div>
      </div>
      <div class="message">
        <div class="meta">匿名 · 2025-08-15 10:25</div>
        <div class="text">这是另一个留言示例。</div>
      </div>
    </div>
  </main>
</body>
    """
    
app.run(host='0.0.0.0',debug=True)